
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>使用frp代理本地机器到公网 · 小白鼠V技术驿站</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="baidu-site-verification" content="cAxqlT3C5k">
        <meta name="author" content="vonchange">
        
        
    
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="/myfile/gitalk/dist/gitalk.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="gitlab-ci.html" />
    
    
    <link rel="prev" href="ubuntu.html" />
    

    <link href="http://www.vonchange.com/rss" title="小白鼠V技术驿站" rel="alternate" type="application/rss+xml" />

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"vonchange","repo":"vonchange.github.io","type":"star","size":"small"}]};
    </script>

    
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    
    
    
    
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="/apple-touch-icon-precomposed-152.png">
    
    
        
    
    
        
    

    
    <link rel="stylesheet" href="../../gitbook/gitbook-plugin-chart/c3/c3.min.css">
    <script src="../../gitbook/gitbook-plugin-chart/c3/d3.min.js"></script>
    <script src="../../gitbook/gitbook-plugin-chart/c3/c3.min.js"></script>
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.vonchange.com/" target="_blank" class="custom-link">小白鼠V的技术博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    博客总揽
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../mini.html">
            
                <a href="../mini.html">
            
                    
                    spring-data-mybatis-mini极简ORM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../host.html">
            
                <a href="../host.html">
            
                    
                    闲置主机做开发服务器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="ubuntu.html">
            
                <a href="ubuntu.html">
            
                    
                    搭建ubuntu server及其k8s
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.2" data-path="frp.html">
            
                <a href="frp.html">
            
                    
                    使用frp代理本地机器到公网
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="gitlab-ci.html">
            
                <a href="gitlab-ci.html">
            
                    
                    搭建gitlab并使用CICD部署HelloWorld
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../idea.html">
            
                <a href="../idea.html">
            
                    
                    IDEA全系列最简单的破解方式
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>

    
    <li>
        
        
        
            
        
        
            <a href="http://www.beian.miit.gov.cn/" target="blank" class="gitbook-link">
                鲁ICP备20022988号
            </a>
        
    </li>
    
</ul>

                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >使用frp代理本地机器到公网</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><ul><li><span class="title-icon "></span><a href="#使用frp代理本地机器到公网"><b>1.1.1. </b>使用frp代理本地机器到公网</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h3 id="使用frp代理本地机器到公网"><a name="使用frp代理本地机器到公网" class="anchor-navigation-ex-anchor" href="#使用frp代理本地机器到公网"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. 使用frp代理本地机器到公网</h3>
<h4 id="首先购买一个最最便宜的服务器"><a name="首先购买一个最最便宜的服务器" class="anchor-navigation-ex-anchor" href="#首先购买一个最最便宜的服务器"><i class="fa fa-link" aria-hidden="true"></i></a>首先购买一个最最便宜的服务器</h4>
<p>突发性能即可(双十一大优惠更好) (我安装的是CentOS 7.2  网络按流量)
<img src="../image/aliecs.jpg" alt="ecs"></p>
<h4 id="安装docker"><a name="安装docker" class="anchor-navigation-ex-anchor" href="#安装docker"><i class="fa fa-link" aria-hidden="true"></i></a>安装docker</h4>
<p>网上教程很多 比如:<a href="https://www.jianshu.com/p/781da23f1b37" target="_blank">https://www.jianshu.com/p/781da23f1b37</a></p>
<pre><code class="lang-angular2html">#!/bin/sh
docker ps
if [ $? -eq 127 ];then
    #docker not found
    yum update -y
    yum install yum-utils device-mapper-persistent-data lvm2 -y
    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    yum install conntrack-tools -y
    yum install docker-ce-18.09.1 -y
    systemctl start docker
    systemctl enable docker
fi

docker ps
</code></pre>
<h4 id="配置镜像加速"><a name="配置镜像加速" class="anchor-navigation-ex-anchor" href="#配置镜像加速"><i class="fa fa-link" aria-hidden="true"></i></a>配置镜像加速</h4>
<p><a href="https://www.runoob.com/docker/docker-mirror-acceleration.html" target="_blank">镜像加速教程</a>
<a href="https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors" target="_blank">阿里云镜像加速</a></p>
<pre><code class="lang-angular2html">sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json &lt;&lt;-&apos;EOF&apos;
{
  &quot;registry-mirrors&quot;: [&quot;https://??.mirror.aliyuncs.com&quot;]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
</code></pre>
<h4 id="服务器安装-frps-server"><a name="服务器安装-frps-server" class="anchor-navigation-ex-anchor" href="#服务器安装-frps-server"><i class="fa fa-link" aria-hidden="true"></i></a>服务器安装 frps server</h4>
<pre><code>-- 先/home/app/ 下弄好配置文件
docker run --restart=unless-stopped  --net=host  -v /home/app/frps:/var/frp/conf --name frps -d registry.cn-hangzhou.aliyuncs.com/change_public/frps:2.0
</code></pre><p>这里直接使用 host 方式 共享主机网路 不用每次接口暴露需要修改
配置文件 frps文件夹下 frps.ini</p>
<pre><code class="lang-angular2html">[common]
bind_addr = 0.0.0.0
bind_port = 7000
kcp_bind_port = 7000
vhost_http_port = 8099
vhost_https_port = 9443
dashboard_addr = 0.0.0.0
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = ?你的密码
authentication_timeout = 0
subdomain_host = frp.?.com
</code></pre>
<p>端口8099 或这tcp端口等需在阿里云安全组里添加映射</p>
<h4 id="本地安装-frpc-client"><a name="本地安装-frpc-client" class="anchor-navigation-ex-anchor" href="#本地安装-frpc-client"><i class="fa fa-link" aria-hidden="true"></i></a>本地安装 frpc client</h4>
<pre><code>docker run  -d \
--net=host \
--name frpc \
--restart unless-stopped \
-v /home/?/data/frpc/config:/var/frp/conf \
registry.cn-hangzhou.aliyuncs.com/change_public/frpc:1.0
</code></pre><blockquote>
<p>配置demo 其他配置详情请参考<a href="https://github.com/fatedier/frp/blob/master/README_zh.md" target="_blank">frp文档</a>
```angular2html
[common]
server_addr = frp.vonchange.com
server_port = 7000
admin_addr = 127.0.0.1
admin_port = 7400
admin_user = admin
admin_pwd = ？</p>
</blockquote>
<p>[web_gitlab]
type=http
local_ip = 127.0.0.1
local_port = 8099
subdomain = gitlab</p>
<p>[ssh_gitlab]
type=tcp
local_ip = 127.0.0.1
local_port = 6022
remote_port = 6022
subdomain = gitlab</p>
<p>[web_k8s]
type=https
local_ip = 127.0.0.1
local_port = 26751
subdomain = k8s</p>
<pre><code>
&gt; 这里 你就可以通过域名访问 你本地的服务做需要大量资源的微服务开发或者其他(个人云存储等)



&lt;script type=&quot;text/javascript&quot;&gt;var targetUl = document.getElementsByClassName(&apos;page-inner&apos;)[0].getElementsByTagName(&apos;ul&apos;)[0];if(targetUl.getElementsByTagName(&apos;a&apos;).length&gt;0){targetUl.className=&apos;toc&apos;;}&lt;/script&gt;

```html
作者: 小白鼠V
链接: http://www.vonchange.com/doc/host/frp.html
来源: 小白鼠V技术驿站
本文原创发布于「小白鼠V技术驿站」,转载请注明出处,谢谢合作!
</code></pre><p><footer class="page-footer"><span class="copyright">© vonchange all right reserved，powered by Gitbook</span><span class="footer-modification">文件修订时间: 
2020-07-01 05:53:23
</span></footer></p>
<div id="gitalk-container"></div>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="ubuntu.html" class="navigation navigation-prev " aria-label="Previous page: 搭建ubuntu server及其k8s">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="gitlab-ci.html" class="navigation navigation-next " aria-label="Next page: 搭建gitlab并使用CICD部署HelloWorld">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"使用frp代理本地机器到公网","level":"1.3.2","depth":2,"next":{"title":"搭建gitlab并使用CICD部署HelloWorld","level":"1.3.3","depth":2,"path":"doc/host/gitlab-ci.md","ref":"doc/host/gitlab-ci.md","articles":[]},"previous":{"title":"搭建ubuntu server及其k8s","level":"1.3.1","depth":2,"path":"doc/host/ubuntu.md","ref":"doc/host/ubuntu.md","articles":[]},"dir":"ltr"},"config":{"plugins":["toc","theme-comscore","pageview-count","-lunr","-search","search-plus","splitter","-sharing","sharing-plus","expandable-chapters-small","anchor-navigation-ex","edit-link-plus","code","chart","favicon-absolute","github-buttons","advanced-emoji","rss","sitemap-general","copyright","tbfed-pagefooter","mygitalk","donate","diff","simple-mind-map","hide-element","audio_image","icp","mermaid-gb3"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"&copy vonchange","modify_label":"文件修订时间: ","modify_format":"YYYY-MM-DD HH:mm:ss"},"diff":{"method":"diffChars","options":{},"type":"markdown"},"splitter":{},"copyright":{"copyProtect":false,"site":"http://www.vonchange.com/","author":"小白鼠V","website":"小白鼠V技术驿站"},"toc":{"addClass":true,"className":"toc"},"edit-link-plus":{"label":"编辑本页","base":{"vonchange.github.io":"https://github.com/VonChange/VonChange.github.io/edit/master"},"defaultBase":"https://github.com/VonChange/VonChange.github.io/edit/master"},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"code":{"copyButtons":true},"donate":{"alipay":"/doc/image/zfb.jpeg","alipayText":"支付宝","button":"赏","title":"","wechat":"/doc/image/wx.jpeg","wechatText":"微信"},"favicon-absolute":{"appleTouchIconMore":{},"appleTouchIconPrecomposed152":"/apple-touch-icon-precomposed-152.png","appleTouchIconPrecomposedMore":{},"favicon":"/favicon.ico"},"sitemap-general":{"prefix":"http://www.vonchange.com/"},"hide-element":{"elements":["a.gitbook-link[href='https://www.gitbook.com']"]},"fontsettings":{"theme":"white","family":"sans","size":2},"rss":{"categories":["orm","k8s","devops","java"],"title":"小白鼠V技术驿站","description":"小白鼠V技术驿站","author":"vonchange","site_url":"http://www.vonchange.com/","feed_url":"http://www.vonchange.com/rss","managingEditor":"vonchange@163.com","webMaster":"vonchange@163.com"},"audio_image":{},"highlight":{},"mermaid-gb3":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"theme-comscore":{},"icp":{"link":"http://www.beian.miit.gov.cn/","style":{},"number":"鲁ICP备20022988号"},"pageview-count":{},"github-buttons":{"buttons":[{"user":"vonchange","repo":"vonchange.github.io","type":"star","size":"small"}]},"expandable-chapters-small":{},"mygitalk":{"flipMoveOptions":{},"clientID":"7f7363b6e6e3c9a06f4f","number":-1,"perPage":10,"proxy":"https://cors-anywhere.herokuapp.com/https://github.com/login/oauth/access_token","admin":["vonchange"],"createIssueManually":false,"distractionFreeMode":false,"repo":"vonchange.github.io","owner":"vonchange","enableHotKey":true,"clientSecret":"6e71673a0cfb622b535af4c00b0622cf2d34d31b","pagerDirection":"last","labels":["Gitalk"]},"advanced-emoji":{"embedEmojis":false},"sharing":{"qq":true,"all":["facebook","google","twitter","weibo","instapaper","linkedin","pocket","stumbleupon"],"douban":true,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":true,"linkedin":false},"simple-mind-map":{"autoFit":true,"linkShape":"diagonal","preset":"colorful","style":{},"type":"markdown"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"chart":{"type":"c3"},"search-plus":{}},"theme":"default","author":"vonchange","baidu-site-verification":"cAxqlT3C5k","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"小白鼠V技术驿站","language":"zh-hans","links":{"sidebar":{"小白鼠V的技术博客":"http://www.vonchange.com/"}},"gitbook":"3.2.3","description":"小白鼠V技术驿站"},"file":{"path":"doc/host/frp.md","mtime":"2020-06-30T21:53:23.025Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-01-10T13:01:43.103Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link-plus/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-rss/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copyright/plugin.js"></script>
        
    
        
        <script src="https://cdn.bootcss.com/blueimp-md5/2.12.0/js/md5.min.js"></script>
        
    
        
        <script src="/myfile/gitalk/dist/gitalk.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-mygitalk/mygitalk.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-simple-mind-map/bundle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    <script src="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

